//go:build wireinject
// +build wireinject

package main

import (
	"blog_go/internal/handler"
	"blog_go/internal/repository"
	"blog_go/internal/server"
	"blog_go/internal/service"
	"blog_go/pkg/helper/jwt"
	"blog_go/pkg/log"

	"github.com/gin-gonic/gin"
	"github.com/google/wire"
	"github.com/spf13/viper"
)

var ServerSet = wire.NewSet(server.NewServerHTTP)

var RepositorySet = wire.NewSet(
	repository.NewBaseDb,
	repository.NewBaseRepository,
	repository.NewUserRepository,
	repository.NewArticleCategoryRepository,
	repository.NewTagRepository,
	repository.NewCollectionRepository,
	repository.NewArticleCommentRepository,
	repository.NewArticleRepository,
)

var ServiceSet = wire.NewSet(
	service.NewService,
	service.NewUserService,
	service.NewArticleCategoryService,
	service.NewTagService,
	service.NewCollectionService,
	service.NewArticleCommentService,
	service.NewArticleService,
)

var HandlerSet = wire.NewSet(
	handler.NewHandler,
	handler.NewUserHandler,
	handler.NewArticleCategoryHandler,
	handler.NewTagHandler,
	handler.NewCollectionHandler,
	handler.NewArticleCommentHandler,
	handler.NewArticleHandler,
)

func newApp(*viper.Viper, *log.Logger) (*gin.Engine, func(), error) {
	panic(wire.Build(
		ServerSet,
		RepositorySet,
		ServiceSet,
		HandlerSet,
		jwt.NewJwt,
	))
}
